package vn.pyco.prez.tapestry.tasks;

import java.io.File;
import java.util.List;

import org.apache.commons.io.FilenameUtils;

import vn.pyco.prez.dao.DaoManager;
import vn.pyco.prez.model.Slide;


public class ConvertionTaskFactory {
	private ConvertionTaskFactory() {}
	
	public static ConvertionTask getConvertionTask(File presentation, DaoManager<List<Slide>> slideManager) {
		String ext = FilenameUtils.getExtension(presentation.getAbsolutePath());
		if (ext.toLowerCase().equals("pptx")) {
			return new ConvertPptxTask(presentation, slideManager);
		} else if(ext.toLowerCase().equals("ppt")){
			return new ConvertPptTask(presentation, slideManager);
		} else if(ext.toLowerCase().equals("opt")){
			throw new UnsupportedOperationException("ODP Files are not supported yet");
		}
		throw new IllegalArgumentException("The file does not have any compatible Extension : pptx, ppt, odp");
	}
}
